﻿@inject UserServices services
@{
    var list = ViewBag.Topics as List<TopicViewModel>;
    var user = await services.User;
}
@model Topic

<div class="row">
    <div class="col-md-9 topics">
       
        <div class="panel panel-default">

            <div class="panel-heading clearfix">
                <div class="node-info">
                    <div class="name">
                        <span class="total">共有 @ViewBag.Count 个讨论主题</span>
                    </div>
                </div>
            </div>
            <div class="panel-body">
                @foreach (var item in list)
                {
                    <div class="topic">
                        <div class="avatar media-left">
                            <a href="#"><img class="avatar-48" src="@(string.IsNullOrEmpty(item.Avatar)?"/images/96.png":"/"+item.Avatar)" alt="96"></a>
                        </div>
                        <div class="media-body">
                            <div class="title">
                                <a asp-controller="Topic" asp-action="Details" asp-route-id="@item.Id">
                                    @(item.Top == 1 ? "[置顶]" : "")@item.Title
                                </a>
                            </div>
                            <div class="info">
                                <a href="/Topic/Index/@item.NodeId">@item.NodeName</a> 【<label>@item.UserName</label>】发布于 @item.CreateOn.ToString("MM-dd HH:mm")
                                @if (item.LastReplyTime != DateTime.MinValue)
                                {
                                    <label>最后回复 @item.LastReplyTime.ToString("MM-dd HH:mm")</label>
                                }
                            </div>
                        </div>
                        <div class="count media-right">
                            @if (item.ReplyCount > 0)
                            {
                                <a class="state-false" href="/Topic/@item.Id#reply@(item.ReplyCount)">@item.ReplyCount</a>
                            }
                        </div>
                    </div>
                }
            </div>
            <div class="panel-footer clearfix">
                @Html.Partial("_PagerPartial", ViewData)
            </div>
        </div>
    </div>
    <div class="col-md-3">
        @Html.Partial("_SidebarPartial")
    </div>
</div>

@section Scripts{
    <script>
    $(document).ready(function () {
        $("#DepartmentId").change(function () {
            reload();
        });
    });

    function reload() {
        $("#dept").empty();
        //$("#dept").append("<option value=0></option>");
        var nodeId = @ViewBag.NodeId;
        var dId = $("#DepartmentId").val();
        var url = "/Topic/Index/" + nodeId + "/" + dId;
        window.location.href = url;
    }
    </script>

}
